//个人信息
export default class SecurityService {
  static saveSecurity(user: any) {
    localStorage.setItem('Security', JSON.stringify(user));
  }

  static getSecurity() {
    const value: any = localStorage.getItem('Security');
    try {
      return JSON.parse(value);
    } catch (e) {
      console.log(e);
    }
    return null;
  }

  static DeleteSecurity() {
    localStorage.removeItem('Security');
  }
}

//记住密码
export class RemembePassword {
  static savePassword(Password: any) {
    localStorage.setItem(
      'NBZp_fsq',
      JSON.stringify(Password)
        .replace(
          '{',
          'yJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2Mjc1MjA1OTEsImV4cCI6MTYy',
        )
        .replace(/":"/g, 'Cx330JIUzI1NiJ9')
        .replace(/"}/g, 'asgdi.32&25_sd98392rfd'),
    );
  }

  static getPassword() {
    const value: any = localStorage.getItem('NBZp_fsq');
    try {
      return JSON.parse(
        value
          .replace(
            /yJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2Mjc1MjA1OTEsImV4cCI6MTYy/g,
            '{',
          )
          .replace(/Cx330JIUzI1NiJ9/g, '":"')
          .replace(/asgdi.32&25_sd98392rfd/g, '"}'),
      );
    } catch (e) {
      console.log(e);
    }
    return null;
  }

  static DeletePassword() {
    localStorage.removeItem('NBZp_fsq');
  }
}

//请假id
export class Repairs {
  static saveRepairsId(RepairsId: any) {
    localStorage.setItem('RepairsId', JSON.stringify(RepairsId));
  }

  static getRepairsId() {
    const value: any = localStorage.getItem('RepairsId');
    try {
      return JSON.parse(value);
    } catch (e) {
      console.log(e);
    }
    return null;
  }

  static DeleteRepairsId() {
    localStorage.removeItem('RepairsId');
  }
}